#include "tagview.h"
#include "ui_tagview.h"
#include <QDebug>

TagView::TagView(int index,QString name,QModelIndex modelIndex,QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::TagView)
{
    ui->setupUi(this);
    label = ui->label;
    btnTag = ui->btn_tag;
    btnClose = ui->btn_close;

    this->name = name;
    this->index = index;
    this->modelIndex = modelIndex;
    QStringList arr = name.split("/");
    btnTag->setText(arr.at(arr.size() - 1));
    this->setAttribute(Qt::WA_DeleteOnClose);
    this->setCursor(Qt::PointingHandCursor);
}

TagView::~TagView()
{
    delete ui;
}

void TagView::routerClick()
{
    on_btn_tag_clicked();
}

void TagView::on_btn_tag_clicked()
{
    emit click();
    setStyleSheet("background-color: rgb(64, 158, 255);color: rgb(255, 255, 255);border:1px solid gray;");
}


void TagView::on_btn_close_clicked()
{
    emit closeTag();
    close();
}

